<template>
  <div class="decoration-wrap">
    <svg :width="width" :height="height">
      <polygon
        :fill="fade(colors[1] || defaultColor[1], 10)"
        :stroke="colors[1]"
        :points="`20 10, 25 4, 55 4 60 10`"
      />

      <polygon
        :fill="fade(colors[1] || defaultColor[1], 10)"
        :stroke="colors[1]"
        :points="`20 ${height - 10}, 25 ${height - 4}, 55 ${height - 4} 60 ${height - 10}`"
      />

      <polygon
        :fill="fade(colors[1] || defaultColor[1], 10)"
        :stroke="colors[1]"
        :points="`${width - 20} 10, ${width - 25} 4, ${width - 55} 4 ${width - 60} 10`"
      />

      <polygon
        :fill="fade(colors[1] || defaultColor[1], 10)"
        :stroke="colors[1]"
        :points="`${width - 20} ${height - 10}, ${width - 25} ${height - 4}, ${width - 55} ${height - 4} ${width - 60} ${height - 10}`"
      />

      <polygon
        :fill="fade(colors[0] || defaultColor[0], 20)"
        :stroke="colors[0]"
        :points="`
          20 10, 5 ${height / 2} 20 ${height - 10}
          ${width - 20} ${height - 10} ${width - 5} ${height / 2} ${width - 20} 10
        `"
      />

      <polyline
        fill="transparent"
        :stroke="fade(colors[0] || defaultColor[0], 70)"
        :points="`25 18, 15 ${height / 2} 25 ${height - 18}`"
      />

      <polyline
        fill="transparent"
        :stroke="fade(colors[0] || defaultColor[0], 70)"
        :points="`${width - 25} 18, ${width - 15} ${height / 2} ${width - 25} ${height - 18}`"
      />
    </svg>

    <div class="decoration-content">
      <slot />
    </div>
  </div>
</template>

<script>
import { fade } from '../../border/util/fade.js'
export default {
  name: 'HzxDecoration',
  props: {
    colors: {
      type: Array,
      default: () => (['#1a98fc', '#2cf7fe'])
    },
    width: {
      type: Number,
      default: 200
    },
    height: {
      type: Number,
      default: 70
    }
  },
  data() {
    return {
      ref: 'decoration-1',
      svgWH: [200, 50]
    }
  },
  mounted() {
    this.svgWH = [this.width, this.height]
  },
  methods: { fade }
}
</script>
<style lang="less" scoped="scoped">
    .decoration-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  .decoration-content {
    position: absolute;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
</style>
